package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Consultant;
import com.hs.mapper.ConsultantMapper;
import com.hs.service.CertificateService;
import com.hs.service.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsultantServiceImpl implements ConsultantService {

    @Autowired
    private ConsultantMapper consultantMapper;
    @Override
    public Integer addConsultant(Consultant consultant) {
        return consultantMapper.addConsultant(consultant);
    }

    @Override
    public Integer deleteConsultant(Integer id) {
        return consultantMapper.deleteConsultant(id);
    }

    @Override
    public Integer updateConsultant(Consultant consultant) {
        return consultantMapper.updateConsultant(consultant);
    }

    @Override
    public Consultant getConsultantById(Integer id) {
        return consultantMapper.getConsultantById(id);
    }

    @Override
    public PageInfo<Consultant> getConsultantPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consultant> allConsultantByPage = consultantMapper.getAllConsultantByPage();
        PageInfo<Consultant> pageInfo = new PageInfo<>(allConsultantByPage);
        return pageInfo;
    }

    @Override
    public PageInfo<Consultant> getAllConsultantlist(Consultant consultant) {
        List<Consultant> list = consultantMapper.getAllConsultantlist(consultant);
        PageInfo<Consultant> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Consultant> getConsultantByLevelName(String levelName,String tag,String address,String gender, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Consultant> consultantByLevelName = consultantMapper.getConsultantByLevelName(levelName,tag,address,gender);
        PageInfo<Consultant> pageInfo = new PageInfo<>(consultantByLevelName);
        return pageInfo;
    }

    @Override
    public List<Consultant> getConsultantByLevelNameAndTag(String levelName, String tag) {
        return consultantMapper.getConsultantByLevelNameAndTag(levelName, tag);
    }
}
